/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.ban.news.server.check.checkers;

import cn.ac.iie.di.ban.news.server.check.CheckResult;
import cn.ac.iie.di.ban.news.server.check.Checker;
import java.util.Collection;
import java.util.HashSet;

/**
 *
 * @author zwlin
 */
public class DomainChecker implements Checker<String, String> {

    private static final HashSet<String> DOMAINS;

    static {
        DOMAINS = new HashSet<>();
        DOMAINS.add("www.test.com");
    }

    public static synchronized void init(Collection<String> domains) {
        DomainChecker.DOMAINS.clear();
        DomainChecker.DOMAINS.addAll(domains);
    }

    @Override
    public CheckResult check(String src, String target) {
        if (true) {
            return new CheckResult();
        }
        if (src == null || !DOMAINS.contains(src)) {
            return new CheckResult("domain not in our list.");
        } else {
            return new CheckResult();
        }
    }

}
